package org.oep.game;

/**
 * This class is mainly just useful for interpolation. Though, some fancy pants stuff
 * could be done in the future.
 * @author pmkilgo
 *
 */
public class Camera {
	private int x, y, subjectX, subjectY;
	private double interpolationFactor = 1.0;
	
	/**
	 * Interpolate by moving a fractional portion of the distance between the current
	 * and ending position.
	 */
	public void interpolate() {
		x += (subjectX - x) * interpolationFactor;
		y += (subjectY - y) * interpolationFactor;
	}
	
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	public int getSubjectX() {
		return subjectX;
	}
	
	public int getSubjectY() {
		return subjectY;
	}
	
	public double getInterpolationFactor() {
		return interpolationFactor;
	}
	
	public void setPosition(int a, int b) {
		x = a;
		y = b;
	}
	
	public void setSubjectPosition(int a, int b) {
		subjectX = a;
		subjectY = b;
	}
	
	/**
	 * This is the fraction that we will interpolate by. Must be in domain (0,1].
	 * @param d, the new interpolation factor.
	 */
	public void setInterpolationFactor(double d) {
		if(d > 0 && d <= 1)
			interpolationFactor = d;
	}
}
